{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <!-- 表单头部 -->
                <div class="box-header with-border">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fa fa-arrow-left"></i>
                            返回
                        </a>
                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post"
                      enctype="multipart/form-data">
                    <input type="hidden" name="ota_account" id="ota_account" value="{$admin.user.account}" />
                    <!-- 表单字段区域 -->
                    <div class="box-body">
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">升级包名</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="name" name="name" value="{$data.name|default=''}"
                                       placeholder="请输入升级包名" type="text" class="form-control field-text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">版本号名</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="version" name="version" value="{$data.version|default=''}"
                                       placeholder="请输入版本号" type="text" class="form-control field-text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">备注</label>
                            <div class="col-sm-10 col-md-4">
                                <textarea name="remark" class="form-control field-text" id="remark"
                                          cols="30" rows="10" placeholder="请输入备注">{$data.remark|default=''}</textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="up_pk" class="col-sm-2 control-label">升级文件</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="up_pk" name="up_pk" placeholder="请上传升级文件" {if
                                       isset($data.up_pk)}data-initial-preview="{$data.up_pk}" {/if} type="file"
                                class="form-control field-image" >
                            </div>
                        </div>
                        <script>
                            $('#up_pk').fileinput({
                                language: 'zh',
                                overwriteInitial: true,
                                browseLabel: '浏览',
                                initialPreviewAsData: true,
                                dropZoneEnabled: false,
                                showUpload: false,
                                showRemove: false,
                                maxFileSize: 30720,
                                allowedFileExtensions: ['rar', 'zip', '7z', 'tar','bin','lua','hex'],
                            });
                        </script>

                        <div class="form-group">
                            <label for="up_pk" class="col-sm-2 control-label"></label>
                            <div class="col-sm-10 col-md-4">
                                <div class="alert alert-danger" role="alert">
                                    *文件类型支持.zip .rar .bin .lua .hex；文件大小不超过30MB；<br/>
                                    文件名称须为1~20个英文、数字、点号、连字符或下划线。
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- 表单底部 -->
                    <div class="box-footer">
                        {:token()}
                        <div class="col-sm-2">
                        </div>
                        <div class="col-sm-10 col-md-4">
                            {if !isset($data)}
                            <div class="btn-group pull-right">
                                <label class="createContinue">
                                    <input type="checkbox" value="1" id="_create" name="_create"
                                           title="继续添加数据">继续添加</label>
                            </div>
                            {/if}
                            <div class="btn-group">
                                <button type="submit" class="btn flat btn-info dataFormSubmit">
                                    保存
                                </button>
                            </div>
                            <div class="btn-group">
                                <button type="reset" class="btn flat btn-default dataFormReset">
                                    重置
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script>
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
            'name': {
                required: true,
            },
            'version': {
                required: true,
            },
            'up_pk': {
                required: true,
            },

        },
        messages: {
            'name': {
                required: "升级包不能为空",
            },
            'version': {
                required: "版本号不能为空",
            },
            'up_pk': {
                required: "升级文件不能为空",
            },

        }
    });
</script>
{/block}